<?php
session_start();
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>XXX图书管理系统</title>
</head>
<body>

<?php
$usertype=$_POST['usertype'];
$userid=$_POST['userid'];
$password=$_POST['password'];

$db=new PDO('mysql:dbname=Library;host=127.0.0.1','root','123456');
$statement=$db->prepare('select * from Users where ID=:id');
$statement->execute([':id'=> $userid]);


$user=$statement->fetch();
if(empty($user))
    echo "用户不存在";
else if($password!=$user['Password']){
    echo '密码不正确';
}else if($usertype!=$user['UsrType']){
    echo '用户身份不正确';
}else {
    $_SESSION['user']=$userid;
    $_SESSION['usertype']=$usertype;
    echo "登陆成功";
}

?>
<a href="index.php">返回首页</a>




</body>
</html>

